<template>
	<view>
		<cu-custom bgColor="bg-gradual-orange" :isBack="true">
			<block slot="content">选择城市</block>
		</cu-custom>
		<gjsSelectCity :scrollHeight="scrollHeight" @select="select"></gjsSelectCity>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import gjsSelectCity from '@/components/gjs-selectCity/gjs-selectCity.vue'
	export default {
		components: {
			gjsSelectCity
		},
		data() {
			return {
				scrollHeight: 800,
			}
		},
		onLoad() {
			this.scrollHeight = uni.getSystemInfoSync().windowHeight * 2
		},
		methods: {
			select(e) {
				console.log('选中的地区', e);
				// 存储数据
				uni.setStorageSync('cityname', e.city);
				uni.$emit('citynameChanged', e.city);  // 触发全局事件
				uni.switchTab({
				    url: '/pages/home/index', // 跳转到购物车页面
				    success: function () {
				        console.log('跳转成功');
				    },
				    fail: function (err) {
				        console.log('跳转失败', err);
				    }
				});
			}
		}
	}
</script>

<style>

</style>
